package visitorPattern;

public class Main {
    public static void main(String[] args) {
        //1. 定义对象结构，通过对象结构访问元素
        Document document = new Document();
        document.addElement(new TextElement("text1"));
        document.addElement(new TextElement("text2"));
        document.addElement(new ImageElement("image1"));
        document.addElement(new ImageElement("image2"));

        //定义访问者，通过访问者访问元素
        document.accept(new ExportVisitor());
        document.accept(new PrintVisitor());
    }
}
